// 导入 request 模块
import request from "@/utils/request.js";

// 创建订单
export const createOrderService = (orderData) => {
    console.log("拿到的订单",orderData)
    return request.post('/order', orderData)
}
// 查询订单
export const orderByIdService = (id) => {
    return request.get(`/order/${id}`)
}
// 标记订单支付成功
export const payOrderService = (id) => {
    return request.put(`/order/pay/${id}`)
}

// 分页查询订单列表
export const orderPageService = (pageQuery) => {
    return request.get('/order/page', { params: pageQuery })
}

// 获取订单详情
export const orderDetailByIdService = (id) => {
    return request.get(`/order/detail/${id}`)
}

// 分页查询退单列表
export const refundPageService = (pageQuery) => {
    return request.get('/order/refund/page', { params: pageQuery })
}

// 退单详情
export const refundDetailByIdService = (id) => {
    return request.get(`/order/refund/detail/${id}`)
}

// 分页查询退单原因列表
export const refundReasonPageService = (pageQuery) => {
    return request.get('/order/reason/page', { params: pageQuery })
}

// 查询回显退单原因
export const refundReasonByIdService = (id) => {
    return request.get(`/order/reason/${id}`)
}

// 添加退单原因
export const refundReasonAddService = (data) => {
    return request.post('/order/reason/', data)
}

// 修改退单原因
export const refundReasonUpdateService = (data) => {
    return request.put('/order/reason/', data)
}

// 逻辑删除退单原因
export const refundReasonDeleteByIdService = (id) => {
    return request.put(`/order/reason/delete/${id}`)
}

// 根据类型查询订单列表
export const orderListByTypeService = (type) => {
    return request.get(`/order/type/${type}`)
}
// 查询最近完成的订单列表
export const orderListRecentService = () => {
    return request.get(`/order/recently`)
}

// 获取本日订单总数
export const orderTodayCountService = () => {
    return request.get(`/order/count/today`)
}

// 获取本月订单总数
export const orderTomonthCountService = () => {
    return request.get(`/order/count/tomonth`)
}

// 获取上月订单总数
export const orderLastmonthCountService = () => {
    return request.get(`/order/count/last_month`)
}